﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.订单一览新.销售确认单
{
    public partial class Form销售统计 : DevExpress.XtraEditors.XtraForm
    {
        private XtraUserControl季度销售统计 xtraUserControl季度销售统计 = new XtraUserControl季度销售统计();
        public Form销售统计()
        {
            InitializeComponent();
        }

        private void textBox款式名称_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.KeyValue == 13)
            {
                if (String.IsNullOrWhiteSpace(this.textBox款式名称.Text.Trim()))
                {
                    return;
                }
                this.label款式.Text = this.textBox款式名称.Text.Trim();
                this.查询销量();
                this.textBox款式名称.Clear();
            }
        }
        private void 查询销量()
        {
            SaleScaleModelDTO saleScaleModelDTO = 销售确认Service.getSaleScaleByStyleNameCn(this.textBox款式名称.Text.Trim());
            //库存
            this.gridControl库存.DataSource = saleScaleModelDTO.saleStockScaleDTOS;
            this.gridView库存.RefreshData();
            this.gridView库存.BestFitColumns();
            this.gridView库存.ExpandAllGroups();
            this.gridView库存.GroupSummary.Add(DevExpress.Data.SummaryItemType.Sum, "quantity", gridColumn数量, "组计:{0}");
            //本日销量
            this.xtraUserControl季度销售统计 = new XtraUserControl季度销售统计(saleScaleModelDTO.currentDaySaleScaleDTOS);
            this.xtraUserControl季度销售统计.Dock = DockStyle.Fill;
            this.panel本日销量.Controls.Clear();
            this.panel本日销量.Controls.Add(this.xtraUserControl季度销售统计);
            //全部销量
            this.xtraUserControl季度销售统计 = new XtraUserControl季度销售统计(saleScaleModelDTO.saleScaleDTOS);
            this.xtraUserControl季度销售统计.Dock = DockStyle.Fill;
            this.panel全部销量.Controls.Clear();
            this.panel全部销量.Controls.Add(this.xtraUserControl季度销售统计);
            //本月销量
            this.xtraUserControl季度销售统计 = new XtraUserControl季度销售统计(saleScaleModelDTO.currentMonthSaleScaleDTOS);
            this.xtraUserControl季度销售统计.Dock = DockStyle.Fill;
            this.panel本月销量.Controls.Clear();
            this.panel本月销量.Controls.Add(this.xtraUserControl季度销售统计);
            //上月销量
            this.xtraUserControl季度销售统计 = new XtraUserControl季度销售统计(saleScaleModelDTO.lastMonthSaleScaleDTOS);
            this.xtraUserControl季度销售统计.Dock = DockStyle.Fill;
            this.panel上月销量.Controls.Clear();
            this.panel上月销量.Controls.Add(this.xtraUserControl季度销售统计);
            //本季度销量
            this.xtraUserControl季度销售统计 = new XtraUserControl季度销售统计(saleScaleModelDTO.currentSeasonSaleScaleDTOS);
            this.xtraUserControl季度销售统计.Dock = DockStyle.Fill;
            this.panel本季度销量.Controls.Clear();
            this.panel本季度销量.Controls.Add(this.xtraUserControl季度销售统计);
            //上季度销量
            this.xtraUserControl季度销售统计 = new XtraUserControl季度销售统计(saleScaleModelDTO.lastSeasonSaleScaleDTOS);
            this.xtraUserControl季度销售统计.Dock = DockStyle.Fill;
            this.panel上季度销量.Controls.Clear();
            this.panel上季度销量.Controls.Add(this.xtraUserControl季度销售统计);

        }

        private void gridView库存_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            try
            {
                if (e.Column.Name.Equals("gridColumn尺码"))
                {
                    if (!String.IsNullOrWhiteSpace(e.DisplayText))
                    {
                        try { e.DisplayText = e.DisplayText.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
                    }
                }
            }
            catch { }
        }
    }
}
